VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOAlmacen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private mvarConnection As utilConexion
Public Property Set Connection(ByVal vData As utilConexion)
    Set mvarConnection = vData
End Property
Public Function getBean(ByVal bean As balmacen) As balmacen
On Error GoTo hnderr
Dim result As balmacen
Dim sql As String
Dim rst As New Recordset
sql = "SELECT c.ncodigo,sdescorta,sdeslarga,nestado "
sql = sql + "FROM Almacen a "
sql = sql + "WHERE a.ncodigo =" + CStr(bean.nCodigo)
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
If Not rst.EOF Then
    Set result = New balmacen
    If Not IsNull(rst.Fields("nCodigo")) Then result.nCodigo = rst.Fields("ncodigo").value
    If Not IsNull(rst.Fields("sdescorta")) Then result.sDescripcionCorta = rst.Fields("sdescorta").value
    If Not IsNull(rst.Fields("sdeslarga")) Then result.sDescripcionLarga = rst.Fields("sdeslarga").value
End If
Set getBean = result
hnderr:
If Err.Number = 0 Then Exit Function
cloneError Err
End Function
Public Function getLista(bean As balmacen) As Collection
On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
Dim list As New Collection
Dim record As New balmacen
sql = "SELECT ncodigo , sdescorta, sdeslarga  "
sql = sql + "FROM almacen "
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
While Not rst.EOF
    Set record = New balmacen
    If Not IsNull(rst.Fields("ncodigo")) Then record.nCodigo = rst.Fields("ncodigo").value
    If Not IsNull(rst.Fields("sdescorta")) Then record.sDescripcionCorta = rst.Fields("sdescorta").value
    If Not IsNull(rst.Fields("sdeslarga")) Then record.sDescripcionLarga = rst.Fields("sdeslarga").value
    rst.MoveNext
    list.Add record
Wend
Set getLista = list
hnderr:
If Err.Number = 0 Then Exit Function
cloneError Err
End Function
